package com.qinggeng.project.system.service.impl;

import com.qinggeng.project.api.dto.OrdersInfoDto;
import com.qinggeng.project.system.domain.OrdersAddress;
import com.qinggeng.project.system.domain.UserAddress;
import com.qinggeng.project.system.mapper.OrdersAddressMapper;
import com.qinggeng.project.system.service.IOrdersAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 订单地址Service业务层处理
 *
 * @author qinggeng
 * @date 2020-06-17
 */
@Service
public class OrdersAddressServiceImpl implements IOrdersAddressService
{
    @Resource
    private OrdersAddressMapper ordersAddressMapper;

    /**
     * 查询订单地址
     *
     * @param ordersAddressId 订单地址ID
     * @return 订单地址
     */
    @Override
    public OrdersAddress selectOrdersAddressById(Long ordersAddressId)
    {
        return ordersAddressMapper.selectOrdersAddressById(ordersAddressId);
    }

    /**
     * 查询订单地址列表
     *
     * @param ordersAddress 订单地址
     * @return 订单地址
     */
    @Override
    public List<OrdersAddress> selectOrdersAddressList(OrdersAddress ordersAddress)
    {
        return ordersAddressMapper.selectOrdersAddressList(ordersAddress);
    }

    /**
     * 新增订单地址
     *
     * @param
     * @return 结果
     */
    @Override
    public int insertOrdersAddress(Long ordersId,UserAddress userAddress)
    {
        OrdersAddress ordersAddress = new OrdersAddress(userAddress);
        ordersAddress.setOrdersId(ordersId);
        ordersAddressMapper.insertOrdersAddress(ordersAddress);
        return ordersAddressMapper.insertOrdersAddress(ordersAddress);
    }

    @Override
    public int insertOrdersAddress(OrdersAddress ordersAddress) {
        return ordersAddressMapper.insertOrdersAddress(ordersAddress);
    }

    /**
     * 修改订单地址
     *
     * @param ordersAddress 订单地址
     * @return 结果
     */
    @Override
    public int updateOrdersAddress(OrdersAddress ordersAddress)
    {
        return ordersAddressMapper.updateOrdersAddress(ordersAddress);
    }

    /**
     * 批量删除订单地址
     *
     * @param ordersAddressIds 需要删除的订单地址ID
     * @return 结果
     */
    @Override
    public int deleteOrdersAddressByIds(Long[] ordersAddressIds)
    {
        return ordersAddressMapper.deleteOrdersAddressByIds(ordersAddressIds);
    }

    /**
     * 删除订单地址信息
     *
     * @param ordersAddressId 订单地址ID
     * @return 结果
     */
    @Override
    public int deleteOrdersAddressById(Long ordersAddressId)
    {
        return ordersAddressMapper.deleteOrdersAddressById(ordersAddressId);
    }

    @Override
    public OrdersAddress selectOrdersAddressByOrdersId(Long ordersId) {
        return ordersAddressMapper.selectOrdersAddressByOrdersId(ordersId);
    }
}
